<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .list-enter-active,
    .list-leave-active {
      transition: all 0.5s ease;
    }
    .list-enter-from,
    .list-leave-to {
      opacity: 0;
      transform: translateX(30px);
    }
  </style>
</head>
<body>
  <div id="app">
    <h2>transitionGroup</h2>
    <!-- transition-group是给多个元素一起加的 -->
    <!-- 相当于给里面的每一个元素都加了transition -->
    <transition-group name="list" tag="ul">
      <li v-for="(item,index) in items" :key="index">
        {{ item }}
        <button @click="remove(item)">删除</button>
      </li>
    </transition-group>
  </div>

  <script src="../vue3.js"></script>
  <script>
    const {createApp} = Vue;

    const app = createApp({
      data() {
        return {
          items: [1,2,3,4,5,6]
        }
      },
      methods: {
        remove(i) {
          this.items = this.items.filter(item => item !== i)
        }
      }
    });

    app.mount("#app");
  </script>
</body>
</html>